package com.nstar.base.weibo
{
	import com.sina.microblog.MicroBlog;
	
	import flash.events.EventDispatcher;
	
	public class WeiboControllerTemplate extends EventDispatcher
	{
		public var debugMode:Boolean = false;
		
		protected var microBlog:MicroBlog;
		
		public function WeiboControllerTemplate()
		{
			microBlog = new MicroBlog();
		}
		
		public function getMicroBlog():MicroBlog{
			return this.microBlog;
		}
		
		//注册微博app key
		public function registerWeibo(appKey:String,debugMode:Boolean=false):MicroBlog{
			if(!appKey){
				throw new Error ( 
					"ERROR WeiboControllerTemplate - registerWeibo() need app key value."
				);
			}
			
			addEventListeners();
			
			//source在监听器处理之后设置
			microBlog.source = appKey;
			//设置为调试模式
			this.debugMode = debugMode;
			microBlog.debugMode = debugMode;
			
			return microBlog;
		}
		
		protected function addEventListeners ():void
		{	
			throw new Error ( 
				"ERROR WeiboControllerTemplate - addEventListeners() primitive operation not implemented."
				+ "\nEvents have not been added to controller" 
			);
		}
				
		public static function getInstance():WeiboControllerTemplate{
			throw new Error (
				"ERROR WeiboControllerTemplate - getInstance primitive operation has not been implemented."
				+ "\nThe Application Controller must be a singleton and provide a concrete implementation of getInstance."
			);

		}

	}
}